
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>基础 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="字符串处理.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="基础.html">
            
                <a href="基础.html">
            
                    
                    基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="字符串处理.html">
            
                <a href="字符串处理.html">
            
                    
                    字符串处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="数据结构.html">
            
                <a href="数据结构.html">
            
                    
                    数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="数据结构高级内容.html">
            
                <a href="数据结构高级内容.html">
            
                    
                    数据结构高级内容
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="函数式编程.html">
            
                <a href="函数式编程.html">
            
                    
                    函数式编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="面向对象编程.html">
            
                <a href="面向对象编程.html">
            
                    
                    面向对象编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="类的特殊方法.html">
            
                <a href="类的特殊方法.html">
            
                    
                    类的特殊方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="IO编程.html">
            
                <a href="IO编程.html">
            
                    
                    IO编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="模块.html">
            
                <a href="模块.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="标准库.html">
            
                <a href="标准库.html">
            
                    
                    标准库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="测试.html">
            
                <a href="测试.html">
            
                    
                    测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="调试.html">
            
                <a href="调试.html">
            
                    
                    调试
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >基础</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x57FA;&#x7840;">&#x57FA;&#x7840;</h1>
<hr>
<h2 id="&#x52A8;&#x6001;&#x8BED;&#x8A00;-vs-&#x9759;&#x6001;&#x8BED;&#x8A00;">&#x52A8;&#x6001;&#x8BED;&#x8A00; vs &#x9759;&#x6001;&#x8BED;&#x8A00;</h2>
<p>&#x52A8;&#x6001;&#x8BED;&#x8A00;&#xFF1A;&#x53D8;&#x91CF;&#x672C;&#x8EAB;&#x7C7B;&#x578B;&#x4E0D;&#x56FA;&#x5B9A;&#x7684;&#x8BED;&#x8A00;;<br>&#x9759;&#x6001;&#x8BED;&#x8A00;&#xFF1A;&#x5728;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x65F6;&#x5FC5;&#x987B;&#x6307;&#x5B9A;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#x679C;&#x8D4B;&#x503C;&#x7684;&#x65F6;&#x5019;&#x7C7B;&#x578B;&#x4E0D;&#x5339;&#x914D;&#xFF0C;&#x5C31;&#x4F1A;&#x62A5;&#x9519;&#x3002;</p>
<h2 id="python&#x89E3;&#x91CA;&#x5668;&#x5E38;&#x89C1;&#x79CD;&#x7C7B;">python&#x89E3;&#x91CA;&#x5668;&#x5E38;&#x89C1;&#x79CD;&#x7C7B;</h2>
<ul>
<li><strong>CPython</strong>&#xFF1A;Python&#x5B98;&#x65B9;&#x7684;&#x89E3;&#x91CA;&#x5668;&#xFF0C;&#x5B83;&#x662F;&#x7528;C&#x8BED;&#x8A00;&#x5F00;&#x53D1;&#x7684;&#xFF0C;&#x662F;&#x76EE;&#x524D;&#x4F7F;&#x7528;&#x6700;&#x5E7F;&#x6CDB;&#x7684;&#x89E3;&#x91CA;&#x5668;&#x3002;  </li>
<li><strong>IPython</strong>&#xFF1A;&#x57FA;&#x4E8E;CPython&#x4E4B;&#x4E0A;&#x7684;&#x4E00;&#x4E2A;&#x4EA4;&#x4E92;&#x5F0F;&#x89E3;&#x91CA;&#x5668;&#xFF0C;&#x4EA4;&#x4E92;&#x65B9;&#x5F0F;&#x4E0A;&#x6709;&#x6240;&#x589E;&#x5F3A;&#xFF0C;&#x4EE3;&#x7801;&#x7684;&#x6267;&#x884C;&#x4E0A;&#x548C;CPython&#x662F;&#x5B8C;&#x5168;&#x4E00;&#x6837;&#x7684;&#x3002;  </li>
<li><strong>Jython</strong>&#xFF1A;&#x8FD0;&#x884C;&#x5728;Java&#x5E73;&#x53F0;&#x4E0A;&#x7684;Python&#x89E3;&#x91CA;&#x5668;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x628A;Python&#x4EE3;&#x7801;&#x7F16;&#x8BD1;&#x6210;Java&#x5B57;&#x8282;&#x7801;&#x6267;&#x884C;&#x3002;  </li>
<li><strong>PyPy</strong>&#xFF1A;&#x5B83;&#x7684;&#x76EE;&#x6807;&#x662F;&#x6267;&#x884C;&#x901F;&#x5EA6;&#x3002;&#x91C7;&#x7528;JIT&#x6280;&#x672F;&#xFF0C;&#x5BF9;Python&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x52A8;&#x6001;&#x7F16;&#x8BD1;&#xFF08;&#x6CE8;&#x610F;&#x4E0D;&#x662F;&#x89E3;&#x91CA;&#xFF09;&#xFF0C;&#x6240;&#x4EE5;&#x53EF;&#x4EE5;&#x663E;&#x8457;&#x63D0;&#x9AD8;Python&#x4EE3;&#x7801;&#x7684;&#x6267;&#x884C;&#x901F;&#x5EA6;&#x3002;  </li>
</ul>
<h2 id="&#x5982;&#x4F55;&#x9000;&#x51FA;&#x89E3;&#x91CA;&#x5668;&#x63D0;&#x793A;&#x7B26;">&#x5982;&#x4F55;&#x9000;&#x51FA;&#x89E3;&#x91CA;&#x5668;&#x63D0;&#x793A;&#x7B26;</h2>
<ul>
<li>&#x4F7F;&#x7528;&#x51FD;&#x6570;<code>exit()</code>  </li>
<li>Linux&#x4E0B;&#x6309; <code>Ctrl+D</code>  </li>
<li>Window&#x4E0B;&#x6309; <code>Ctrl+Z</code> &#x518D;&#x6309;Enter  </li>
</ul>
<h2 id="&#x8BED;&#x8A00;&#x7279;&#x70B9;">&#x8BED;&#x8A00;&#x7279;&#x70B9;</h2>
<ul>
<li>&#x5927;&#x5C0F;&#x5199;&#x654F;&#x611F;&#x7684;  </li>
<li><code>#!/usr/bin/python3</code>&#x8FD9;&#x884C;&#x544A;&#x8BC9;Linux&#x7CFB;&#x7EDF;&#x5E94;&#x8BE5;&#x8FD0;&#x884C;&#x54EA;&#x4E2A;&#x89E3;&#x91CA;&#x5668;&#x3002;  </li>
<li>&#x9ED8;&#x8BA4;&#x6240;&#x6709;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x7F16;&#x7801;&#x662F; Unicode  </li>
<li>&#x6309;&#x7167;&#x7EA6;&#x5B9A;&#x4FD7;&#x6210;&#x7684;&#x7BA1;&#x7406;&#xFF0C;&#x5E94;&#x8BE5;&#x59CB;&#x7EC8;&#x575A;&#x6301;&#x4F7F;&#x7528; 4 &#x4E2A;&#x7A7A;&#x683C;&#x7684;&#x7F29;&#x8FDB;&#x3002;  </li>
</ul>
<h2 id="&#x83B7;&#x5F97;&#x5E2E;&#x52A9;">&#x83B7;&#x5F97;&#x5E2E;&#x52A9;</h2>
<ul>
<li>help(&#x51FD;&#x6570;&#x540D;)&#xFF0C;&#x4F8B;&#x5982;<code>help(print)</code>  </li>
<li>help(&apos;&#x64CD;&#x4F5C;&#x7B26;&#x540D;&#x5B57;&apos;)&#xFF0C;&#x4F8B;&#x5982;<code>help(&apos;return&apos;)</code><br>&#x6309;q&#x952E;&#x9000;&#x51FA;&#x5E2E;&#x52A9;&#x3002;  </li>
</ul>
<h2 id="&#x6CE8;&#x91CA;">&#x6CE8;&#x91CA;</h2>
<p>&#x4EE5;#&#x5F00;&#x5934;&#x7684;&#x4E3A;&#x6CE8;&#x91CA;&#x3002;<br>&#x4F8B;&#x5982;&#xFF1A;  </p>
<pre><code class="lang-python"><span class="hljs-comment">#this is a note</span>
print(<span class="hljs-string">&apos;hello python&apos;</span>)  <span class="hljs-comment">#this is a note</span>
</code></pre>
<h2 id="&#x903B;&#x8F91;&#x884C;&#x548C;&#x7269;&#x7406;&#x884C;">&#x903B;&#x8F91;&#x884C;&#x548C;&#x7269;&#x7406;&#x884C;</h2>
<ol>
<li>&#x884C;&#x8FDE;&#x63A5;&#xFF0C;&#x4F7F;&#x7528;&#x53CD;&#x659C;&#x6760;\&#x6765;&#x7EED;&#x884C;  <pre><code class="lang-python">s = <span class="hljs-string">&apos;hello \
world&apos;</span>
</code></pre>
</li>
<li>&#x4F7F;&#x7528;&#x5206;&#x53F7;&#x53EF;&#x4EE5;&#x5C06;&#x591A;&#x4E2A;&#x903B;&#x8F91;&#x884C;&#x5199;&#x5728;&#x4E00;&#x4E2A;&#x7269;&#x7406;&#x884C;  <pre><code class="lang-python">a = <span class="hljs-number">5</span>; print(a)
</code></pre>
</li>
</ol>
<h2 id="&#x5355;&#x8BED;&#x53E5;&#x5757;">&#x5355;&#x8BED;&#x53E5;&#x5757;</h2>
<p>&#x5982;&#x679C;&#x4F60;&#x7684;&#x8BED;&#x53E5;&#x5757;&#x53EA;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x8BED;&#x53E5;&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x53EF;&#x4EE5;&#x5728;&#x6761;&#x4EF6;&#x8BED;&#x53E5;&#x6216;&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x7684;&#x540C;&#x4E00;&#x884C;&#x6307;&#x660E;&#x5B83;&#x3002;  </p>
<pre><code class="lang-python"><span class="hljs-keyword">if</span> <span class="hljs-keyword">True</span>: print(<span class="hljs-string">&apos;yes&apos;</span>)
</code></pre>
<h2 id="pass&#x8BED;&#x53E5;">pass&#x8BED;&#x53E5;</h2>
<p>&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x7A7A;&#x7684;&#x8BED;&#x53E5;&#x5757;  </p>
<h2 id="del&#x8BED;&#x53E5;">del&#x8BED;&#x53E5;</h2>
<ol>
<li>&#x5220;&#x9664;&#x53D8;&#x91CF;(&#x5220;&#x9664;&#x4E4B;&#x540E;&#x5C06;&#x65E0;&#x6CD5;&#x518D;&#x4F7F;&#x7528;&#x8BE5;&#x53D8;&#x91CF;)  <pre><code class="lang-python">a, mylist, mydict = <span class="hljs-number">100</span>, [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>], {<span class="hljs-string">&apos;a&apos;</span>:<span class="hljs-number">1</span>, <span class="hljs-string">&apos;b&apos;</span>:<span class="hljs-number">2</span>}
<span class="hljs-keyword">del</span> a
<span class="hljs-keyword">del</span> mylist
<span class="hljs-keyword">del</span> mydict
</code></pre>
</li>
<li>&#x5220;&#x9664;&#x5217;&#x8868;&#x5143;&#x7D20;  <pre><code class="lang-python"><span class="hljs-keyword">del</span> mylist[<span class="hljs-number">0</span>]    <span class="hljs-comment">#&#x5220;&#x9664;&#x5217;&#x8868;&#x6307;&#x5B9A;&#x5143;&#x7D20;</span>
<span class="hljs-keyword">del</span> mylist[<span class="hljs-number">0</span>:<span class="hljs-number">1</span>]  <span class="hljs-comment">#&#x5220;&#x9664;&#x5217;&#x8868;&#x5207;&#x7247;</span>
<span class="hljs-keyword">del</span> mylist[:]    <span class="hljs-comment">#&#x5220;&#x9664;&#x6574;&#x4E2A;&#x5217;&#x8868;</span>
</code></pre>
</li>
<li>&#x5220;&#x9664;&#x5B57;&#x5178;&#x7684;&#x4E00;&#x4E2A;&#x952E;&#x503C;&#x5BF9;  <pre><code class="lang-python"><span class="hljs-keyword">del</span> mydict[<span class="hljs-string">&apos;a&apos;</span>]
</code></pre>
</li>
</ol>
<h2 id="&#x4E09;&#x5143;&#x64CD;&#x4F5C;&#xFF08;conditional-expressions&#xFF09;">&#x201C;&#x4E09;&#x5143;&#x201D;&#x64CD;&#x4F5C;&#xFF08;Conditional expressions&#xFF09;</h2>
<p>&#x8BED;&#x6CD5;&#xFF1A;<code>x if Condition else y</code><br>&#x8BF4;&#x660E;&#xFF1A;&#x5982;&#x679C;Condition&#x4E3A;&#x771F;&#xFF0C;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x503C;&#x4E3A;x, &#x5426;&#x5219;&#x4E3A;y&#x3002;<br>&#x4E3E;&#x4F8B;&#xFF1A;  </p>
<pre><code class="lang-python">ret = <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">False</span> <span class="hljs-keyword">else</span> <span class="hljs-number">0</span>   <span class="hljs-comment">#ret&#x7684;&#x503C;&#x4E3A;0</span>
</code></pre>
<h2 id="with&#x8BED;&#x53E5;">with&#x8BED;&#x53E5;</h2>
<p>&#x57FA;&#x672C;&#x8BED;&#x6CD5;&#xFF1A;  </p>
<pre><code>with EXPRESSION [as VARIABLE]:
    DO_SOMETHING
</code></pre><p>&#x57FA;&#x672C;&#x601D;&#x60F3;&#x662F;with&#x5BF9;&#x8868;&#x8FBE;&#x5F0F;&#x6240;&#x6C42;&#x503C;&#x7684;&#x5BF9;&#x8C61;&#x5FC5;&#x987B;&#x6709;&#x4E00;&#x4E2A;<code>__enter__()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x4E00;&#x4E2A;<code>__exit__()</code>&#x65B9;&#x6CD5;&#x3002;<br>&#x6B65;&#x9AA4;&#x5206;&#x89E3;&#xFF1A;<br>1&#xFF09;&#x9996;&#x5148;&#x5BF9; <code>EXPRESSION</code> &#x8BED;&#x53E5;&#x6C42;&#x503C;&#xFF0C;&#x6C42;&#x503C;&#x540E;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF1B;<br>2&#xFF09;&#x5BF9;&#x8C61;&#x7684;<code>__enter__()</code>&#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x5C06;&#x88AB;&#x8D4B;&#x503C;&#x7ED9;as&#x540E;&#x9762;&#x7684;VARIABLE&#x53D8;&#x91CF;&#xFF1B;<br>3&#xFF09;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x5757;<code>DO_SOMETHING</code>&#xFF1B;<br>4&#xFF09;&#x5BF9;&#x8C61;&#x7684; <code>__exit__()</code> &#x65B9;&#x6CD5;&#x88AB;&#x8C03;&#x7528;&#xFF1B;  </p>
<p>&#x5BF9;&#x5F02;&#x5E38;&#x7684;&#x5904;&#x7406;&#xFF1A;<br>1&#xFF09;&#x5982;&#x679C;<code>__enter__</code>&#x6210;&#x529F;&#x6267;&#x884C;&#xFF0C;&#x5219;<code>__exit__</code>&#x603B;&#x662F;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#xFF1B;<br>2&#xFF09;&#x5982;&#x679C;&#x5728;&#x5BF9;<code>VARIABLE</code>&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x7684;&#x65F6;&#x5019;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#xFF0C;&#x5B83;&#x5C06;&#x548C;&#x9519;&#x8BEF;&#x53D1;&#x751F;&#x5728;<code>DO_SOMETHING</code>&#x4E00;&#x6837;&#x5BF9;&#x5F85;&#xFF1B;<br>3&#xFF09;&#x5982;&#x679C;&#x5728;&#x6267;&#x884C;<code>DO_SOMETHING</code>&#x4EE3;&#x7801;&#x5757;&#x53D1;&#x751F;&#x5F02;&#x5E38;&#xFF0C;&#x5B83;&#x7684;<code>type,value,traceback</code>&#x5C06;&#x4F1A;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x4F20;&#x7ED9;<code>__exit__</code>&#xFF1B;&#x5426;&#x5219;&#xFF0C;&#x5C06;&#x4F20;&#x4E09;&#x4E2A;None&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#xFF1B;<br>4&#xFF09;&#x5982;&#x679C;&#x6267;&#x884C;<code>__exit__</code>&#x65F6;&#x5F62;&#x53C2;&#x4E2D;&#x68C0;&#x6D4B;&#x5230;&#x5F02;&#x5E38;&#xFF0C;&#x6267;&#x884C;&#x5B8C;&#x540E;&#xFF0C;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;False&#x5219;&#x5F02;&#x5E38;&#x5C06;&#x518D;&#x6B21;&#x629B;&#x51FA;&#xFF1B;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;True&#xFF0C;&#x5219;&#x5F02;&#x5E38;&#x88AB;&#x8BA4;&#x4E3A;&#x5DF2;&#x7ECF;&#x5904;&#x7406;&#xFF1B;  </p>
<p>&#x4F8B;1&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">My</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span>
        print(<span class="hljs-string">&apos;init...&apos;</span>)
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__enter__</span><span class="hljs-params">(self)</span>:</span>
        print(<span class="hljs-string">&apos;enter...&apos;</span>)
        <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;123&apos;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__exit__</span><span class="hljs-params">(self, exc_type, exc_value, traceback)</span>:</span>  <span class="hljs-comment">#__exit__&#x65B9;&#x6CD5;&#x7684;&#x5F62;&#x53C2;&#x4E2D;&#x63CF;&#x8FF0;&#x4E86;&#x5F02;&#x5E38;&#x4FE1;&#x606F;</span>
        print(<span class="hljs-string">&apos;exit...&apos;</span>)
<span class="hljs-keyword">with</span> My() <span class="hljs-keyword">as</span> var:
    print(var)
</code></pre>
<p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#x4E3A;&#xFF1A;  </p>
<pre><code>init...
enter...
123
exit...
</code></pre><p>&#x4F8B;2&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-keyword">with</span> open(<span class="hljs-string">&quot;myfile.txt&quot;</span>) <span class="hljs-keyword">as</span> f:
    <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> f:
        print(line, end=<span class="hljs-string">&quot;&quot;</span>)
</code></pre>
<p>&#x5728;&#x6267;&#x884C;&#x5B8C;&#x540E;&#xFF0C;&#x6587;&#x4EF6; f &#x5C31;&#x4F1A;&#x88AB;&#x81EA;&#x52A8;&#x5173;&#x95ED;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 前言">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="字符串处理.html" class="navigation navigation-next " aria-label="Next page: 字符串处理">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"基础","level":"1.2","depth":1,"next":{"title":"字符串处理","level":"1.3","depth":1,"path":"字符串处理.md","ref":"字符串处理.md","articles":[]},"previous":{"title":"前言","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"基础.md","mtime":"2017-08-24T15:59:31.822Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-08-27T04:11:18.522Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

